
from django.db import models

# UNUSABLE_PASSWORD is still imported here for backwards compatibility


    
class Restaurant(models.Model):
        
    name = models.CharField( max_length=50, unique=False)
    anothername = models.CharField( max_length=50, unique=False)
    tastestyle = models.DecimalField( max_digits=10, decimal_places=0 ) 
    address = models.CharField( max_length=100, unique=False)  
    nearby = models.CharField( max_length=100, unique=False)
    gpsposition_x = models.IntegerField( )
    gpsposition_y = models.IntegerField( )
    
    phone1 = models.CharField( max_length=20, unique=False)  
    phone2 = models.CharField( max_length=20, unique=False)
    
    open = models.CharField(max_length=5, unique=False)
    close = models.CharField(max_length=5, unique=False)
    
    howtogetthere = models.CharField( max_length=100, unique=False)
    administrator = models.CharField( max_length=30, unique=True )    
    
    queuestartflag = models.BooleanField( )
    queuenextcallnum = models.IntegerField( ) #next number will be called
    queuenextdistributenum  = models.IntegerField( ) #next will be distribute number ,that's also means the queue's maximum number  
    
   
        
    def startqueue(self):
        self.queuestartflag = True
        self.queuenextcallnum = 0
        self.queuenextdistributenum = 0
        self.save()
    def stopqueue(self):
        self.queuestartflag = False
        self.queuenextcallnum = 0
        self.queuenextdistributenum = 0
        self.save()
    def getqueueworkingflag(self):
        return self.queuestartflag
    
    def querycurrentlinemaxnumber(self):
        return self.querycurrentlinemaxnumber()
    
    def jointhequeueline(self):
        self.queuenextdistributenum = self.queuenextdistributenum + 1
        self.save()
        return self.queuenextdistributenum
    
    def callnextone(self):
        self.queuenextcallnum = self.queuenextcallnum + 1
        self.save()
        
    def getnextcallnumber(self):
        return self.queuenextcallnum
        
        
    